package com.yanqu.road.server.cmd.manor;

import com.yanqu.road.pb.manor.ManorProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.manor.ManorModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/5/19 10:28
 */
@Cmd(code = GameProtocol.S_MANOR_HARVEST, desc = "庄园收获")
public class ManorHarvestCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ManorModule.class).harvest();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            ManorProto.ManorHarvestRespMsg.Builder respMsg = ManorProto.ManorHarvestRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_MANOR_HARVEST, respMsg);
        }
    }
}
